package me.haoliang.akka

import javax.annotation.PostConstruct

import akka.actor.{ActorRef, ActorSystem, Props}
import com.typesafe.config.ConfigFactory
import org.slf4j.{Logger, LoggerFactory}
import org.springframework.context.annotation.Lazy
import org.springframework.stereotype.Component

/**
  * author: planck 
  * createTime: 2016/10/31.
  */
@Component
@Lazy(value = false)
class SpringActor {


  val logger:Logger = LoggerFactory.getLogger(classOf[SpringActor])
  var actorSystem: ActorSystem = _
  var actorRef: ActorRef = _

  @PostConstruct
  def init() = {
    logger.info("actor start")
    actorSystem = ActorSystem.create("myActorService", ConfigFactory.load("akka/testApplication.conf"))
    actorRef = actorSystem.actorOf(Props[AkkaListener], "myActor")
  }


}
